<?php
class DispatchUtil{
	public static function canEditTech(DispatchTech $tech){
		if($tech->complete !='Y' && $tech->dispatchModel!=null && empty($tech->dispatchModel->complete)){
			return true;
		}
		return false;
	}

	public static function canEditDispatch(Dispatchdetails $dispatch){
		return (empty($dispatch->complete));
	}

	public static function sendNoticeEmail($dispatch,$empno){
		$employee= Employees::model()->findByPk($empno);
		if(Yii::app()->user->isGuest == false){
			$sender= Yii::app()->user->model->real_name;
			if($employee!=null && $employee->unassign !='Y'){
				$body = <<<HERE
				$employee->firstname $employee->lastname,
				<br/>
				<br/>
				You have been assigned Dispatch No: $dispatch<br/>
				Please download/acknowledge the dispatch and follow your normal procedures.<br/>
				<br/>
				Best Regards,<br/>
				<br/>
				$sender
HERE;
				$subject = 'QSI: New Assigned Dispatch No: '.$dispatch;
				EmailUtil::sendEmail($subject,$employee->workemail,$body);
			}
		}
		
	}
}